package com.link.server.controller;

import com.link.common.core.LinkResponse;
import com.link.server.ws.WebSocketChannel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/token")
public class TokenValidController {


    @GetMapping("/valid")
    public LinkResponse valid(String token){
       var account= WebSocketChannel.getByToken(token);
        if(account!=null){
            return LinkResponse.ok(account.getId())   ;

        }else{
           return  LinkResponse.error("token无效");
        }

    }
}
